package scau.erps.view.decision.sand;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class LinePanel extends JPanel{
	private static final long serialVersionUID = 1L;
	private String product;
	private String type;
	private int value;
	private JPanel typePanel;
	private JLabel productLabel;
	public LinePanel(String product,String type,int value){
		super();
		this.product = product;
		this.type = type;
		this.value = value;
		JPanel linePanel = new JPanel();
		linePanel.setBorder(BorderFactory.createEtchedBorder());
		linePanel.setLayout(new BorderLayout());
		linePanel.setPreferredSize(new Dimension(50,160));
		productLabel = new JLabel();
		productLabel.setText(product);
		productLabel.setHorizontalAlignment(JLabel.CENTER);
		JLabel valueLabel = new JLabel();
		valueLabel.setText(Integer.toString(value));
		valueLabel.setHorizontalAlignment(JLabel.CENTER);
		linePanel.add(productLabel,BorderLayout.NORTH);
		linePanel.add(getTypePanel(type),BorderLayout.CENTER);
		linePanel.add(valueLabel,BorderLayout.SOUTH);
		this.add(linePanel);		
	}
	public JPanel getTypePanel(String type){
		typePanel = new JPanel();
		typePanel.setPreferredSize(new Dimension(40,140));
		if("手工线".equals(type)){
			typePanel.setLayout(new GridLayout(3,1,5,5));
			JTextField jtf1 = new JTextField();
			JTextField jtf2 = new JTextField();
			JTextField jtf3 = new JTextField();			
			jtf1.setEnabled(false);
			jtf2.setEnabled(false);
			jtf3.setEnabled(false);
			typePanel.add(jtf1);
			typePanel.add(jtf2);
			typePanel.add(jtf3);
		}
		else if("半自动".equals(type)){
			typePanel.setLayout(new GridLayout(2,1,5,5));
			JTextField jtf1 = new JTextField();
			JTextField jtf2 = new JTextField();
			jtf1.setEnabled(false);
			jtf2.setEnabled(false);
			typePanel.add(jtf1);
			typePanel.add(jtf2);
		}
		else if("全自动".equals(type)){
			typePanel.setLayout(new GridLayout(1,1,5,5));
			JTextField jtf1 = new JTextField();
			jtf1.setEnabled(false);
			typePanel.add(jtf1);			
		}
		else if("柔性线".equals(type)){
			productLabel.setText("Any");
			typePanel.setLayout(new GridLayout(1,1,5,5));
			JTextField jtf1 = new JTextField();
			jtf1.setEnabled(false);
			typePanel.add(jtf1);			
		}
		else if(product==null && type==null){
			productLabel.setText("None");			
		}
		return typePanel;		
	}

	public String getProduct() {
		return product;
	}
	public void setProduct(String product) {
		this.product = product;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public int getValue() {
		return value;
	}
	public void setValue(int value) {
		this.value = value;
	}
	

}
